/**
 * @(#)HeaderView.java 2011
 *
 *  Copyright 2011 classic-commerce
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 * @author: <a href="mailto:richard@ioniq.ca">Richard Mutezintare</a>
 *
 */
package ca.ioniq.client.view;

import ca.ioniq.client.ClassicMessages;
import ca.ioniq.client.widget.ErrorMessageWidget;
import ca.ioniq.client.widget.header.CartSummaryWidget;
import ca.ioniq.client.widget.header.HeaderMenuWidget;
import ca.ioniq.client.widget.header.LoginWidget;
import ca.ioniq.client.widget.header.WelcomeWidget;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author: <a href="mailto:richard@ioniq.ca">Richard Mutezintare</a>
 */
public class HeaderView extends Composite {

    private final String HEADER_ID = "header";

    private HeaderMenuWidget headerMenu;
    private LoginWidget loginWidget;
    private WelcomeWidget welcomeWidget;
    private CartSummaryWidget cartSummaryWidget;

    public HeaderView(ErrorMessageWidget errors, ClassicMessages messages) {
        FlowPanel panel = new FlowPanel();

        welcomeWidget = new WelcomeWidget(messages);
        welcomeWidget.setVisible(false);

        panel.add(welcomeWidget);

        headerMenu = new HeaderMenuWidget(messages);
        panel.add(headerMenu);

        cartSummaryWidget = new CartSummaryWidget(messages);
        panel.add(cartSummaryWidget);



        // this widget is invisible until requested by the user
        loginWidget = new LoginWidget(errors, messages);
        loginWidget.setVisible(false);
        panel.add(loginWidget);

        panel.getElement().setId(HEADER_ID);

        initWidget(panel);
    }

    public Widget asWidget() {
        return asWidget();
    }

    public HeaderMenuWidget getHeaderMenu() {
        return headerMenu;
    }

    public LoginWidget getLoginWidget() {
        return loginWidget;
    }

    public WelcomeWidget getWelcomeWidget() {
        return welcomeWidget;
    }

    public CartSummaryWidget getCartSummaryWidget() {
        return cartSummaryWidget;
    }
}
